package com.hanahina.CourseDesign;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Random;

public class MyCanvas extends Canvas{
	Random random=new Random();
	private int x=random.nextInt(500);
	private int y=random.nextInt(50);
	private int score=0;
	private ArrayList<DataInfo> list;
	private Color color;
	
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public ArrayList<DataInfo> getList() {
		return list;
	}
	public void setList(ArrayList<DataInfo> list) {
		this.list = list;
	}
	public Color getColor() {
		return color;
	}
	public void setColor(Color color) {
		this.color = color;
	}
	
	public MyCanvas(int x, int y, Color color) {
		this.x=x;
		this.y=y;
		this.color=color;
		list=new ArrayList<DataInfo>();
		DataInfo dataInfo1=new DataInfo("A", 30, 0, 0);
		list.add(dataInfo1);
		DataInfo dataInfo2=new DataInfo("H", 60, -50, 0);
		list.add(dataInfo2);
		DataInfo dataInfo3=new DataInfo("F", 90, -20, 0);
		list.add(dataInfo3);
		DataInfo dataInfo4=new DataInfo("W", 125, -30, 0);
		list.add(dataInfo4);
	}
	
	public void paint(Graphics g) {
		super.paint(g);
		g.setFont(new Font("微软雅黑", Font.BOLD, 20));
		g.setColor(Color.BLACK);
		g.drawLine(10, 325, 475, 325);
		g.drawString("score:"+this.score, 10, 350);
		g.setColor(color);
		for (int i = 0; i < list.size(); i++) {
			g.drawString(list.get(i).getStr(), list.get(i).getX(), list.get(i).getY());
		}
	}
	
	
}
